<?php

/*
 * 系统设置页面
 */
?>
<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class C_System extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('System_Model');
        $this->load->model('Users_Model');
    }

    public function index() {
        $data['title'] = $this->System_Model->get_system('login_title');
        $this->load->view('layout/header', $data);
        $this->load->view('layout/menu');
        $this->load->view('system/system_view');
        $this->load->view('layout/footer');
    }

    //初始化界面
    public function syste_init() {
        $this->load->view('system/system_init_view');
    }

    //异步获取初始化界面信息，插入数据库
    function ajax_insert() {
        $systemName = $this->input->post('systemName');
        $userName = $this->input->post('userName');
        $u_userName = $this->input->post('uuserName');
        $password = $this->input->post('password');
        //初始化标题
        $this->System_Model->insert_system($systemName);

        //添加管理员
        $data = array(
            'u_name' => $userName,
            'u_userName' => $u_userName,
            'u_password' => $password,
            'u_admin' => 1,
            'u_state' => OBJ_STATE_VALID
        );
        $result = $this->Users_Model->Insert_User($data);

        //添加权限
        $roleData = array(
            'u_id' => $result,
            'ro_content' => "10001,10002,10003,10004"
        );
        $result = $this->Role_Model->Insert_Role($result, $roleData);
        echo $result;
    }

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */